package com.wcarmon.life.business {

    import com.adobe.cairngorm.business.ServiceLocator;
    import com.adobe.cairngorm.business.IServiceLocator;
    import com.adobe.cairngorm.commands.ICommand
    import com.adobe.cairngorm.control.CairngormEvent;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.IResponder;
	import mx.controls.Alert;
	import flash.utils.*;
	
	
	public class GetReviewDelegate {
		include "../../includes/loggerSnippet.as";
		
		private var responder : IResponder;
		private var service : Object;
		
		public function GetReviewDelegate( responder : IResponder ){
			this.service = ServiceLocator.getInstance().getRemoteObject("LifeReviewService");
			this.responder = responder;
			log.info( 'Using this php file: ' + this.service.source );
		}
		public function getReview( rt : String ) : void {
			log.debug("getting review.  type=" + rt);
			var call : Object;
			
			switch( rt ){
				case 'daily' : call = service.getDailyReviews();			break; 
				case 'weekly' : call = service.getWeeklyReviews();			break;
				case 'monthly' : call = service.getMonthlyReviews();		break;
				case 'quarterly' : call = service.getQuarterlyReviews();	break;
				case 'yearly' : call = service.getYearlyReviews();			break;
				default:
					log.fatal("Code error: Invalid review type! '" + rt + "'");	
					Alert.show("Code Error: invalid review type: " + rt);
			}
			call.addResponder( responder );
		}
	}
}